<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Class windows_shared_memory</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../boost_interprocess_reference.html#header.boost.interprocess.windows_shared_memory_hpp" title="Header &lt;boost/interprocess/windows_shared_memory.hpp&gt;">
<link rel="prev" href="upgradable_lock.html" title="Class template upgradable_lock">
<link rel="next" href="xsi_key.html" title="Class xsi_key">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="upgradable_lock.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_interprocess_reference.html#header.boost.interprocess.windows_shared_memory_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="xsi_key.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.interprocess.windows_shared_memory"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class windows_shared_memory</span></h2>
<p>boost::interprocess::windows_shared_memory</p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../boost_interprocess_reference.html#header.boost.interprocess.windows_shared_memory_hpp" title="Header &lt;boost/interprocess/windows_shared_memory.hpp&gt;">boost/interprocess/windows_shared_memory.hpp</a>&gt;

</span>
<span class="keyword">class</span> <a class="link" href="windows_shared_memory.html" title="Class windows_shared_memory">windows_shared_memory</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// <a class="link" href="windows_shared_memory.html#boost.interprocess.windows_shared_memoryconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="windows_shared_memory.html#idp57511952-bb"><span class="identifier">windows_shared_memory</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="windows_shared_memory.html#idp57512656-bb"><span class="identifier">windows_shared_memory</span></a><span class="special">(</span><a class="link" href="create_only_t.html" title="Struct create_only_t">create_only_t</a><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span><span class="special">,</span> <span class="identifier">mode_t</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">,</span> 
                        <span class="keyword">const</span> <a class="link" href="permissions.html" title="Class permissions">permissions</a> <span class="special">&amp;</span> <span class="special">=</span> <a class="link" href="permissions.html" title="Class permissions">permissions</a><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="windows_shared_memory.html#idp57515488-bb"><span class="identifier">windows_shared_memory</span></a><span class="special">(</span><a class="link" href="open_or_create_t.html" title="Struct open_or_create_t">open_or_create_t</a><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span><span class="special">,</span> <span class="identifier">mode_t</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">,</span> 
                        <span class="keyword">const</span> <a class="link" href="permissions.html" title="Class permissions">permissions</a> <span class="special">&amp;</span> <span class="special">=</span> <a class="link" href="permissions.html" title="Class permissions">permissions</a><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="windows_shared_memory.html#idp57518384-bb"><span class="identifier">windows_shared_memory</span></a><span class="special">(</span><a class="link" href="open_only_t.html" title="Struct open_only_t">open_only_t</a><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span><span class="special">,</span> <span class="identifier">mode_t</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="windows_shared_memory.html#idp57519856-bb"><span class="identifier">windows_shared_memory</span></a><span class="special">(</span><a class="link" href="windows_shared_memory.html" title="Class windows_shared_memory">windows_shared_memory</a> <span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  windows_shared_memory&amp; <a class="link" href="windows_shared_memory.html#idp57520768-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="windows_shared_memory.html" title="Class windows_shared_memory">windows_shared_memory</a> <span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="windows_shared_memory.html#idp57521664-bb"><span class="special">~</span><span class="identifier">windows_shared_memory</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="windows_shared_memory.html#idp57508656-bb">public member functions</a></span>
  <span class="keyword">void</span> <a class="link" href="windows_shared_memory.html#idp57508864-bb"><span class="identifier">swap</span></a><span class="special">(</span><a class="link" href="windows_shared_memory.html" title="Class windows_shared_memory">windows_shared_memory</a> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <a class="link" href="windows_shared_memory.html#idp57510016-bb"><span class="identifier">get_name</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">mode_t</span> <a class="link" href="windows_shared_memory.html#idp57510656-bb"><span class="identifier">get_mode</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">mapping_handle_t</span> <a class="link" href="windows_shared_memory.html#idp57511280-bb"><span class="identifier">get_mapping_handle</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idp81262064"></a><h2>Description</h2>
<p>A class that wraps the native Windows shared memory that is implemented as a file mapping of the paging file. Unlike <a class="link" href="shared_memory_object.html" title="Class shared_memory_object">shared_memory_object</a>, <a class="link" href="windows_shared_memory.html" title="Class windows_shared_memory">windows_shared_memory</a> has no kernel persistence and the shared memory is destroyed when all processes destroy all their <a class="link" href="windows_shared_memory.html" title="Class windows_shared_memory">windows_shared_memory</a> objects and mapped regions for the same shared memory or the processes end/crash.</p>
<p>Warning: Windows native shared memory and interprocess portable shared memory (<a class="link" href="shared_memory_object.html" title="Class shared_memory_object">boost::interprocess::shared_memory_object</a>) can't communicate between them. </p>
<div class="refsect2">
<a name="idp81264928"></a><h3>
<a name="boost.interprocess.windows_shared_memoryconstruct-copy-destruct"></a><code class="computeroutput">windows_shared_memory</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="idp57511952-bb"></a><span class="identifier">windows_shared_memory</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Default constructor. Represents an empty <code class="computeroutput"><a class="link" href="windows_shared_memory.html" title="Class windows_shared_memory">windows_shared_memory</a></code>. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idp57512656-bb"></a><span class="identifier">windows_shared_memory</span><span class="special">(</span><a class="link" href="create_only_t.html" title="Struct create_only_t">create_only_t</a><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> name<span class="special">,</span> <span class="identifier">mode_t</span> mode<span class="special">,</span> 
                      <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> size<span class="special">,</span> 
                      <span class="keyword">const</span> <a class="link" href="permissions.html" title="Class permissions">permissions</a> <span class="special">&amp;</span> perm <span class="special">=</span> <a class="link" href="permissions.html" title="Class permissions">permissions</a><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>
<p>Creates a new native shared memory with name "name" and mode "mode", with the access mode "mode". If the file previously exists, throws an error. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idp57515488-bb"></a><span class="identifier">windows_shared_memory</span><span class="special">(</span><a class="link" href="open_or_create_t.html" title="Struct open_or_create_t">open_or_create_t</a><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> name<span class="special">,</span> <span class="identifier">mode_t</span> mode<span class="special">,</span> 
                      <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> size<span class="special">,</span> 
                      <span class="keyword">const</span> <a class="link" href="permissions.html" title="Class permissions">permissions</a> <span class="special">&amp;</span> perm <span class="special">=</span> <a class="link" href="permissions.html" title="Class permissions">permissions</a><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>
<p>Tries to create a shared memory object with name "name" and mode "mode", with the access mode "mode". If the file previously exists, it tries to open it with mode "mode". Otherwise throws an error. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idp57518384-bb"></a><span class="identifier">windows_shared_memory</span><span class="special">(</span><a class="link" href="open_only_t.html" title="Struct open_only_t">open_only_t</a><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> name<span class="special">,</span> <span class="identifier">mode_t</span> mode<span class="special">)</span><span class="special">;</span></pre>
<p>Tries to open a shared memory object with name "name", with the access mode "mode". If the file does not previously exist, it throws an error. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idp57519856-bb"></a><span class="identifier">windows_shared_memory</span><span class="special">(</span><a class="link" href="windows_shared_memory.html" title="Class windows_shared_memory">windows_shared_memory</a> <span class="special">&amp;&amp;</span> moved<span class="special">)</span><span class="special">;</span></pre>
<p>Moves the ownership of "moved"'s shared memory object to *this. After the call, "moved" does not represent any shared memory object. Does not throw </p>
</li>
<li class="listitem">
<pre class="literallayout">windows_shared_memory&amp; <a name="idp57520768-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><a class="link" href="windows_shared_memory.html" title="Class windows_shared_memory">windows_shared_memory</a> <span class="special">&amp;&amp;</span> moved<span class="special">)</span><span class="special">;</span></pre>
<p>Moves the ownership of "moved"'s shared memory to *this. After the call, "moved" does not represent any shared memory. Does not throw </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idp57521664-bb"></a><span class="special">~</span><span class="identifier">windows_shared_memory</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Destroys *this. All mapped regions are still valid after destruction. When all mapped regions and <code class="computeroutput"><a class="link" href="windows_shared_memory.html" title="Class windows_shared_memory">windows_shared_memory</a></code> objects referring the shared memory are destroyed, the operating system will destroy the shared memory. </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="idp81298864"></a><h3>
<a name="idp57508656-bb"></a><code class="computeroutput">windows_shared_memory</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idp57508864-bb"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="windows_shared_memory.html" title="Class windows_shared_memory">windows_shared_memory</a> <span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>Swaps to shared_memory_objects. Does not throw. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <a name="idp57510016-bb"></a><span class="identifier">get_name</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Returns the name of the shared memory. </li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">mode_t</span> <a name="idp57510656-bb"></a><span class="identifier">get_mode</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Returns access mode. </li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">mapping_handle_t</span> <a name="idp57511280-bb"></a><span class="identifier">get_mapping_handle</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Returns the mapping handle. Never throws. </li>
</ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2005-2012 Ion Gaztanaga<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="upgradable_lock.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_interprocess_reference.html#header.boost.interprocess.windows_shared_memory_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="xsi_key.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
